import {getTop} from "@/http/api";

export default {
    namespaced: true,//开启命名空间
    state: {
        topList:[]
    },
    mutations: {
        GETTOPLIST(state,data){
            state.topList = data.list
        }
    },
    actions: {
        async getTop({commit}){
            const result = await getTop()
            commit('GETTOPLIST',result.data)
        }
    },
    getters: {
        ChineseTop(state){
            let indexList = ['3','0','2','1']
            let li = state.topList.slice(0,4)
            li.forEach((item,index)=>{
                item.detailId = indexList[index]
            })
            return li || []
        },

        OtherTop(state){

            return state.topList.slice(4,state.topList.length - 1) || []
        },
        }
}
